package com.lecture.java8.stream;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * @program: spring-lecture
 * @description:
 * @author: luyn
 * @create: 2020-03-28 20:43
 **/
public class TestStreamApi {

    public void test1() {
        List<Integer> list = Arrays.asList(1, 7, 2, 1, 8, 12, 45);
        list.stream().map((item) -> item * item).forEach(System.out::println);
        Optional<Integer> reduce = list.stream()
                .reduce((x, y) -> x * y);
        System.out.println(reduce);
    }

    public static void main(String[] args) {
        TestStreamApi testStreamApi = new TestStreamApi();
        testStreamApi.test1();
    }
}
